<?php
/**
  * FAQ 添加
  * faqAdd.php
  * 模板文件：faqAdd.html
  */
include_once("global.php");
include_once("functions/faq.class.php");
include_once("lang/".$CONFIG->lang."/faq.lang.php");

$faq = new faq;

//$DB->debug = true;
//取得参数
$question 	= trim($_REQUEST["question"]);
$reply		= trim($_REQUEST["reply"]);
$fiType		= $_REQUEST["fiType"];
$act		= $_REQUEST["act"];
//

$errmsg = "";
if($act == "add"){
	if(empty($question))	$errmsg .= $lang["question_cannot_null"];
	if(empty($reply))	$errmsg .= $lang["reply_cannot_null"];
	if(empty($fiType))	$errmsg .= $lang["type_cannot_null"];
}

if($act == "add" && $errmsg == ""){
	if($faq->add($question, $reply, $fiType))
	$errmsg = $lang["add_success"];
}
//模板设置
$smarty = $COMMON->template_init();

$smarty -> assign(array(
			"errmsg"		=> $errmsg,
			"op_id"			=> $GLOBAL["OP_ID"],
			"question"		=> $question,
			"reply"			=> $reply,
			"fitypeOption"	=> $COMMON->getOptionsString($GLOBAL["DATA"]->faqType, $fiType),
		));

$smarty->display("faqAdd.html");
?>